//
//  MOPersonInfoCell.m
//  MobileOffice
//
//  Created by 晓 on 2019/6/7.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOPersonInfoCell.h"

@interface MOPersonInfoCell ()

@property (nonatomic, strong) UILabel *titleLabel;

@end

@implementation MOPersonInfoCell

+ (instancetype)cellWithTableView:(UITableView *)tableview {
    static NSString *cellID = @"MOPersonInfoCell";
    MOPersonInfoCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[MOPersonInfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupCell];
    }
    return self;
}

- (void)setupCell{
    [self addSubview:self.titleLabel];
    [self addSubview:self.contentLabel];
    [self addSubview:self.userImageView];
}

- (void)setModel:(MOPersonInfoModel *)model{
    _model = model;
    if ([model.titleStr isEqualToString:@"头像"]) {
        self.titleLabel.centerY = kHConversions(73)/2;
    }
    else{
        self.titleLabel.centerY = kHConversions(54)/2;
    }
    self.titleLabel.text = model.titleStr;
    self.contentLabel.text = model.contentStr;
}


#pragma mark -懒加载
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kWConversions(60), kHConversions(15))];
        _titleLabel.font = FONT_SIZE(15);
        _titleLabel.textColor = KFontBlackColor;
    }
    return _titleLabel;
}

- (UILabel *)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_titleLabel.frame) + 10, 0,SCREEN_WIDTH - 30 - CGRectGetWidth(_titleLabel.frame) - 10 , kHConversions(15))];
        _contentLabel.centerY = kHConversions(54)/2;
        _contentLabel.font = FONT_SIZE(15);
        _contentLabel.textColor = KFontLightColor;
        _contentLabel.textAlignment = NSTextAlignmentRight;
    }
    return _contentLabel;
}

- (UIImageView *)userImageView{
    if (!_userImageView) {
        _userImageView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 15 - kHConversions(59), 0, kHConversions(59), kHConversions(59))];
        _userImageView.centerY = kHConversions(73)/2;
        _userImageView.image = IMAGE(@"user_default");
        _userImageView.layer.masksToBounds = YES;
        _userImageView.layer.cornerRadius = kHConversions(59)/2;
    }
    return _userImageView;
}

@end
